<script setup lang="jsx">
import { isHttps } from "@/utils"

defineProps({
  icon: {
    type: String,
    default: "",
  },
  size: {
    type: String,
    default: "18",
  },
  showName: {
    type: Boolean,
    default: true,
  },
})

</script>

<template>
  <div v-if="icon" class="render-menu-icon">
    <el-image :style="{width: `${size}px`, height: `${size}px`}" v-if="isHttps(icon)" :src="icon" />
    <template v-else>
      <el-icon :size="parseFloat(size)">
        <component :is="icon" />
      </el-icon>
      <span class="icon-name" v-if="showName">{{ icon }}</span>
    </template>
  </div>
  <span v-else>--</span>
</template>

<style scoped lang="less">
.render-menu-icon {
  display: flex;
  align-items: center;
  .icon-name {
    margin-left: 4px;
    font-size: 12px;
  }
}
</style>
